import React from 'react';
import u from '../common.js'
import ReactDOM from 'react-dom';
import '../static/postbar.less'
import { Button, message } from 'antd';



class Postbar extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            detailList:[],
            flag: true,
            index: 0,
            num: null,
            id: null
        }
    }

    componentWillMount () {
        
    }

    componentDidMount () {
        this.setState({
            // id: localStorage.getItem("ID"),
            num: Number(localStorage.getItem("NUM"))
        })
        let num = Number(localStorage.getItem("NUM"))
        console.log(localStorage.getItem("ID"))
        let id = localStorage.getItem("ID")
        if (num === 2) {
            // 数据抓取列表
             this.getDetail(id)
        } else {    
            // 处置列表
            this.getDetail2(id)
        }
    }

    getDetail (id) {
        u.searchId({
            id: id
        },data => {
            console.log(data)
            // if (data.indexContent)
            this.setState({
                detailList: data.indexContent
            })
        })
    }

    getDetail2 (id) {
        console.log(33333)
        console.log(id)
        u.searchId2({
            id: id
        },data => {
            this.setState({
                detailList: data.actionData
            })
        })
    }

    // onPanBlack(id) {
    //     u.blackId({
    //         id: id
    //     }, data => {
    //         message.success('判黑成功')
    //     })
    //     setTimeout(function(){ window.close(); }, 2000);
        
    // }

    // onPanWhite(id) {
    //     u.whiteId({
    //         id: id
    //     }, data => {
    //         message.success('判白成功')
    //     })
    //     setTimeout(function(){ window.close(); }, 2000);
    // }

    render() {
        return (
            <div className='postbar'>
                <div className='nav_bc' style={{display:'block'}}>
                    <h3>{this.state.num ===2? this.state.detailList.account_nickname:this.state.detailList.title}</h3>
                    <div className='nav_bc_title'>
                        <div className="nav_style">
                            <div>
                                <span><b>发布时间：</b>{this.state.num ==2? this.state.detailList.publish_time:this.state.detailList.create_time}</span><br />
                                <span><b>QQ：</b>{this.state.detailList.qq}</span><br />
                                <span><b>邮箱：</b>{this.state.detailList.e_mail}</span><br />
                                <span><b>抓取时间：</b>{this.state.detailList.crawl_time}</span>
                            </div>
                            <div className="nav_left">
                                <span><b>来源：</b>{this.state.detailList.source}</span><br />
                                <span><b>微信：</b>{this.state.detailList.weixinhao}</span><br />
                                <span><b>电话号码：</b>{this.state.detailList.phone}</span><br />
                                <span><b>域名：</b>{this.state.detailList.domain}</span>
                            </div>
                        </div>
                    </div>
                    <div className='nav_bc_title'>
                    <span><b>网址：</b><a target="_blank" href={this.state.detailList.account_url?this.state.detailList.account_url:this.state.detailList.url}>{this.state.num ===2? this.state.detailList.account_url:this.state.detailList.url}</a></span></div>
                </div>
                <div className='nav_b_left nav_bc_left'>
                    <div className='nav_b_left_content' style={{display:'block'}}>
                        <div className='nav_b_left_son'>
                            <p><span>内容：</span><br />
                            {this.state.detailList.content?this.state.detailList.content:''}
                            {this.state.detailList.description?this.state.detailList.description:''}
                            {this.state.detailList.comments?this.state.detailList.comments: ''}
                            <span></span></p>
                        </div>
                    </div> 
                </div>
                {/* {
                    this.state.num === 2 ? <div className="buttonStyle">
                        <Button type="danger" onClick={this.onPanBlack.bind(this,this.state.id)}>判黑</Button>
                        <Button onClick={this.onPanWhite.bind(this,this.state.id)}>判白</Button>
                    </div> : ''
                } */}
                
            </div>
        )
    }
}




export default Postbar